local base = piece "base"
local jammersturret = piece "jammersturret"
local deploy = piece "deploy"
local jam1 = piece "jam1"
local jam2 = piece "jam2"
local cylinder = piece "cylinder"
local turret = piece "turret"

local function Open()
        Signal(2)
        SetSignalMask(1)

	Move(deploy, y_axis, 25, 10)
	Turn(jam1, z_axis, 0.2, 0.1)
	Turn(jam2, z_axis, -0.2, 0.1)

        Spin(jammersturret, y_axis, 0.3, 0.01)
        Spin(turret, y_axis, -0.5, 0.01)
        Spin(cylinder, y_axis, 1.2, 0.05)
        return true
end

local function Close()
        Signal(1)
        SetSignalMask(2)
	
	Move(deploy, y_axis, 0, 10)
        Turn(jam1, z_axis, 0, 0.1)
        Turn(jam2, z_axis, 0, 0.1)

        StopSpin(jammersturret, y_axis, 0.01)
        StopSpin(turret, y_axis, 0.01)
        StopSpin(cylinder, y_axis, 0.01)
        return true
end

function script.Activate ( )
        StartThread( Open )

end

function script.Deactivate ( )
        StartThread( Close )
end
